package com.njwb.day10.Dvd;

import java.util.ArrayList;
import java.util.Scanner;

public class Main {
    private static final DvdService dvdService = new DvdServiceImpl();
    private static Scanner sc = new Scanner(System.in);
    public static void main(String[] args) {
        moren();
        while(true) {
            System.out.println("1、添加dvd\n" +
                    "2、删除dvd\n" +
                    "3、查询dvd\n" +
                    "4、借出dvd\n" +
                    "5、归还did\n" +
                    "6、查看dvd的借出排行数据\n" +
                    "7、退出");
            int operate=sc.nextInt();
            switch (operate){
                case 1:
                    add();break;
                case 2:
                    delete();break;
                case 3:
                    select();break;
                case 4:
                    loan();break;
                case 5:
                    returns();break;
                case 6:
                    showdesc();break;
                case 7:
                    System.exit(0);
                    break;
                default:
                    System.out.println("操作无效！！！");


            }
        }
    }
    public static void moren(){
        dvdService.moren();
    }
    public static void add(){
        System.out.println("请输入Dvd名字：");
        String name= sc.next();
        System.out.println(dvdService.add(name));

    }
    public static void delete(){
        System.out.println("请输入Dvd名字：");
        String name= sc.next();
        System.out.println(dvdService.delete(name));
    }
    public static void select(){
        System.out.println("请输入Dvd名字：");
        String name= sc.next();
        System.out.println(dvdService.select(name));
    }
    public static void loan(){
        System.out.println("请输入Dvd名字：");
        String name= sc.next();
        System.out.println(dvdService.loan(name));
    }
    public static void returns(){
        System.out.println("请输入Dvd名字：");
        String name= sc.next();
        System.out.println(dvdService.returns(name));

    }
    public static void showdesc(){
        ArrayList<Dvds> sortedList = dvdService.showdesc();
        for (Dvds dd : sortedList) {
            System.out.println(dd); // 自动调用 toString() 方法
        }
    }



}
